import {
	IParam,
	IUIActionResult,
	IActionModel,
	IContext,
	IAbility,
	IHttpResponse,
	deepCopy,
	IViewAbility,
	srfpluralize,
	hasFunction,
	formatUrlString,
    IRedirectInput,
    transformDoData
} from '@/core';
import { Http } from '@/http';
import { EntityUIServiceBase } from '../entity-ui-service-base';
import CustomEditUILogic from './custom-edit-ui-logic';
import CustomViewFormLoadUILogic from './custom-view-form-load-ui-logic';
import CustomViewGridLoadUILogic from './custom-view-grid-load-ui-logic';
import FormLoadUILogic from './form-load-ui-logic';
import GridLoadUILogic from './grid-load-ui-logic';
import PrintParamsUILogic from './print-params-ui-logic';
import CancelSelectUILogic from './cancel-select-ui-logic';
import CustomViewDestroyUILogic from './custom-view-destroy-ui-logic';
import Grid_loadUILogic from './grid-load-ui-logic';
import SetRouteParamUILogic from './set-route-param-ui-logic';
import Uilogic_testUILogic from './uilogic-test-ui-logic';
import Uilogic_test_testUILogic from './uilogic-test-test-ui-logic';
import UilogictestUILogic from './uilogictest-ui-logic';
import DynamicActionPlugin from '@/plugins/ui-action/dynamic-action-plugin/dynamic-action-plugin';

/**
 * 图书UI服务对象基类
 * 基于template/src/ui-service/{{appEntities}}/{{appEntities}}-ui-service-base.ts.hbs生成
 *
 * @export
 * @class IBIZBOOKUIServiceBase
 * @extends {UIService}
 */
export class IBIZBOOKUIServiceBase extends EntityUIServiceBase {

	/**
   * Creates an instance of IBIZBOOKUIServiceBase
   * 
   * @param {*} [opts={}]
   * @memberof IBIZBOOKUIServiceBase
   */
  constructor(opts: IParam = {}) {
    super(opts);
    this.appDeKeyFieldName = 'ibizbookid';
		// 是否启用主状态
		this.isEnableDEMainState = true;
		// 主状态属性集合
		this.mainStateFields = ['type'];
    // 主状态集合Map
      this.allDeMainStateMap.set('仙侠', '仙侠');
      this.allDeMainStateMap.set('都市', '都市');
      this.allDeMainStateMap.set('武侠', '武侠');
      // 主状态操作标识Map
      this.allDeMainStateOPPrivsMap.set(
			'仙侠',
			Object.assign({ 'CREATE':1,'DELETE':1,'EDIT':1,'OPEN_DOCUMENT':1,'READ':1,'UPDATE':1 }, { 'DELETE':0 })
		);
      this.allDeMainStateOPPrivsMap.set(
			'都市',
			Object.assign({ 'CREATE':1,'DELETE':1,'EDIT':1,'OPEN_DOCUMENT':1,'READ':1,'UPDATE':1 }, { 'EDIT':0 })
		);
      this.allDeMainStateOPPrivsMap.set(
			'武侠',
			Object.assign({ 'CREATE':1,'DELETE':1,'EDIT':1,'OPEN_DOCUMENT':1,'READ':1,'UPDATE':1 }, { 'OPEN_DOCUMENT':0 })
		);
  	}


	/**
	 * 导出测试
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async DataExportTest(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'SINGLEKEY',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	let url: string = '/ibizbooks/exportdata/fetchdefault';
    	if (context.srfparentdename && context.srfparentkey) {
    		url = `/${srfpluralize(context.srfparentdename).toLowerCase()}/${context.srfparentkey}` + url;
    	}
    	url += '?srfexporttag=DataExport';
    	const params: IParam = { page: 0, size: 1000 };
    	try {
    		const response = await Http.getHttp()({
    			url: url,
    			method: 'post',
    			data: params,
    			responseType: 'blob'
    		});
    		if (!response || (response.status && response.status !== 200)) {
    			return { ok: false, data: [] };
    		}
    		const fileName: string = decodeURIComponent('图书.xlsx');
    		let blob = new Blob([response.data], { type: 'application/vnd.ms-excel' });
    		let elink = document.createElement('a');
    		elink.download = fileName;
    		elink.style.display = 'none';
    		elink.href = URL.createObjectURL(blob);
    		document.body.appendChild(elink);
    		elink.click();
    		URL.revokeObjectURL(elink.href); // 释放URL 对象
    		document.body.removeChild(elink);
    		return await this.afterAction(context, viewParams, data, event, ability, actionModel);
    	} catch (error: any) {
    		try {
    			const reader = new FileReader();
    			reader.readAsText(error.data, 'utf-8');
    			reader.onload = (event: any) => {
    				const message = JSON.parse(event.target.result)?.message;
    				App.getNotificationHelper().error('错误', message ? message : '导出失败');
    			}
    		} catch (error) {
    			App.getNotificationHelper().error('错误', '导出失败');
    		}
    		return { ok: false, data: [] };
    	}
  }

	/**
	 * 导入测试
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async DataImportTest(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'SINGLEKEY',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	const view = {
    		appEntityCodeName: '',
    		codeName: 'AppDataUpload',
    		caption: '数据导入',
    		name: 'app-data-upload',
    		width: 544,
    		height: 368
    	}
    	if (!(context.srfparentdename && context.srfparentkey)) {
    		if (context.srfparentdename) {
    			delete context.srfparentdename;
    		}
    		if (context.srfparentkey) {
    			delete context.srfparentkey;
    		}
    	}
    	const actionResult: IUIActionResult = await App.getOpenViewHelper().openModal(view, context, Object.assign({
    		importId: 'DataImport',
    		serviceName: 'IBIZBOOK',
    		appDeLogicName: '图书'
    	}, viewParams));
    	if (actionResult.ok) {
    		if (ability && (ability as unknown as IViewAbility).refresh instanceof Function) {
    			(ability as unknown as IViewAbility).refresh(viewParams);
    		}
    		return await this.afterAction(context, viewParams, data, event, ability, actionModel);
    	} else {
    		return { ok: false, data: [] };
    	}
  }

	/**
	 * 删除
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async Delete(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'SINGLEKEY',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	try {
    		if (ability && hasFunction(ability, 'validate') && (actionModel.actionTarget=='SINGLEDATA' || actionModel.actionTarget=='MULTIDATA')) {
    			//	校验(暂时只考虑表格与表单)
    			if (!(await (ability as any).validate())) {
    				//	提示信息待确认
    				return { ok: false, data: [] };
    			}
    		}
    		//  获取实体服务
    		const dataService = await App.getDataService('IBIZBOOK', context);
    		if (context.srfsessionid) {
    			Object.assign(context, { srfsessionkey: context.srfsessionid });
    			delete context.srfsessionid;
    		}
    	    const tempData = data[0];
    		const response: IHttpResponse = await dataService['Remove'](context, tempData);
    		if (!response.success) {
    			App.getNotificationHelper().error(App.ts('common.generic.error'),response.message || '');
    			return { ok: false, data: [] };
    		}
    		return await this.afterAction(context, viewParams, response.data, event, ability, actionModel);
    	} catch (error: any) {
    		App.getNotificationHelper().error(App.ts('common.generic.error'),error.message || '');
    	  	return { ok: false, data: error };
    	}
  }

	/**
	 * 编辑
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async Edit(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'SINGLEKEY',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	// 根据视图名称 获取视图详情
    	const view = App.getAppViewConfig()['IBIZBOOKUsr3EditView'];
    	if (!view) {
    		App.getNotificationHelper().warning('', '目标视图不存在');
    		return { ok: false, data: [] };
    	}
    	// 打开视图
    	App.getOpenViewHelper().openIndexViewTab(view, context, viewParams);
    	return await this.afterAction(context, viewParams, data, event, ability, actionModel);
  }

	/**
	 * 自定义测试
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async TestCustom(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'SINGLEKEY',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	eval(`console.log(data);`);
    	return await this.afterAction(context, viewParams, data, event, ability, actionModel);
  }

	/**
	 * 加载草稿book数据
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async loadbook(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'NONE',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	try {
    		if (ability && hasFunction(ability, 'validate') && (actionModel.actionTarget=='SINGLEDATA' || actionModel.actionTarget=='MULTIDATA')) {
    			//	校验(暂时只考虑表格与表单)
    			if (!(await (ability as any).validate())) {
    				//	提示信息待确认
    				return { ok: false, data: [] };
    			}
    		}
    		//  获取实体服务
    		const dataService = await App.getDataService('IBIZBOOK', context);
    		if (context.srfsessionid) {
    			Object.assign(context, { srfsessionkey: context.srfsessionid });
    			delete context.srfsessionid;
    		}
    	    const tempData = data[0];
    		const response: IHttpResponse = await dataService['GetDraft'](context, tempData);
    		if (!response.success) {
    			App.getNotificationHelper().error(App.ts('common.generic.error'),response.message || '');
    			return { ok: false, data: [] };
    		}
    		return await this.afterAction(context, viewParams, response.data, event, ability, actionModel);
    	} catch (error: any) {
    		App.getNotificationHelper().error(App.ts('common.generic.error'),error.message || '');
    	  	return { ok: false, data: error };
    	}
  }

	/**
	 * 逻辑-之后
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async logic_afert(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'NONE',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			uILogicAttachMode: 'AFTER',
			deUILogicTag: 'grid_load',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	window.open(
    		formatUrlString(
    			'http://www.baidu.com/',
    			context,
    			viewParams,
    			data && data.length ? data[0] : {}
    		),
    		'_blank'
    	);
    	return await this.afterAction(context, viewParams, data, event, ability, actionModel);
  }

	/**
	 * 打开百度（插件行为）
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async openBaiduPlugin(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
			const dynamicactionplugin = new DynamicActionPlugin(this);
			return await dynamicactionplugin.execute(uiContext, uiViewParams, uiData, event, ability);
  }

	/**
	 * 打开自定义编辑视图
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async openCustomEditView(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'SINGLEKEY',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	// 根据视图名称 获取视图详情
    	const view = App.getAppViewConfig()['IBIZBOOKFormLoadCustomView'];
    	if (!view) {
    		App.getNotificationHelper().warning('', '目标视图不存在');
    		return { ok: false, data: [] };
    	}
    	// 打开视图
    	const actionResult = await App.getOpenViewHelper().openPage(view, context, viewParams);
    	if (actionResult && actionResult.ok) {
    		return await this.afterAction(context, viewParams, data, event, ability, actionModel);
    	} else {
    		return { ok: false, data: [] };
    	}
  }

	/**
	 * 打开文档
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async openDocument(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'SINGLEKEY',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	window.open(
    		formatUrlString(
    			'https://www.yuque.com/ibiz/wuf19n',
    			context,
    			viewParams,
    			data && data.length ? data[0] : {}
    		),
    		'_blank'
    	);
    	return await this.afterAction(context, viewParams, data, event, ability, actionModel);
  }

	/**
	 * 打开实体看板文档
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async openKanbanDocument(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'NONE',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	window.open(
    		formatUrlString(
    			'https://www.yuque.com/ibiz/wuf19n/tqi7p6',
    			context,
    			viewParams,
    			data && data.length ? data[0] : {}
    		),
    		'_blank'
    	);
    	return await this.afterAction(context, viewParams, data, event, ability, actionModel);
  }

	/**
	 * 打开百度
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async openbaidu(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
        const actionModel: IActionModel = {
            actionTarget: 'NONE',
			reloadData: false,
			refreshMode: 0,
			entityCodeName: 'IBIZBOOK',
			keyFieldCodeName: 'IBIZBOOKId',
            majorFieldCodeName: 'IBIZBOOKName',
			closeEditView: false,
		};
		// 根据行为目标 合并行为参数
		const { context, viewParams, data } = await this.handleUIActionParam(uiContext, uiViewParams, uiData, actionModel);
    	window.open(
    		formatUrlString(
    			'https://www.baidu.com/',
    			context,
    			viewParams,
    			data && data.length ? data[0] : {}
    		),
    		'_blank'
    	);
    	return await this.afterAction(context, viewParams, data, event, ability, actionModel);
  }

	/**
	 * 编辑
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async panel_Usr1109586119_button_calluilogic2_click(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
		//	替换执行界面逻辑
		return await this.executeUILogic('CustomEdit', uiContext, uiViewParams, uiData, event, ability);
  }

	/**
	 * 测试界面逻辑
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async testuilogic(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
		//	替换执行界面逻辑
		return await this.executeUILogic('uilogictest', uiContext, uiViewParams, uiData, event, ability);
  }

	/**
	 * 加载
	 *
	 * @param {*} params
	 * @memberof IBIZBOOKUIServiceBase
	 */
  public async toolbar_CustomView_layouttoolbar_deuiaction1_click(
    uiContext: IContext,
    uiViewParams: IParam,
    uiData: IParam[],
    event: MouseEvent,
    ability: IAbility
  ): Promise<IUIActionResult> {
		//	替换执行界面逻辑
		return await this.executeUILogic('GridLoad', uiContext, uiViewParams, uiData, event, ability);
  }

  /**
    * 获取指定数据的重定向页面
    * 
    * @param context 应用上下文 
    * @param viewParams 视图参数
    * @param data 业务数据
    * @param redirectParam 重定向视图输入参数
	* @memberof IBIZBOOKUIServiceBase
    */
    public async getAppRDView(
        context: IContext,
		viewParams: IParam,
		data: IParam,
		redirectParam: IRedirectInput
    ){
        // 进行数据查询
        const service = await App.getDataService("IBIZBOOK", context);
        const tempContext: IContext = deepCopy(context);
        const key: string = 'ibizbook';
        let srfkey: string | null = null;
        if (data && data.hasOwnProperty(key)) {
            srfkey = data[key];
        } else if (context && context[key]) {
            srfkey = context[key];
        } else if (viewParams && viewParams[key]) {
            srfkey = viewParams[key];
        }
        Object.assign(tempContext, { [key]: srfkey });
        let result: any;
        if (redirectParam.redirectAction && service[redirectParam.redirectAction] && service[redirectParam.redirectAction] instanceof Function) {
            result = await service[redirectParam.redirectAction](tempContext, data);
        } else {
            result = await service.Get(tempContext, data);
        }
        const curData:any = result.data;
        // 判断当前数据模式,默认为true,todo
        const iRealDEModel:boolean = true;
        let bDataInWF: boolean = false;
		let bWFMode:any = false;
		if (redirectParam.isEnableWorkflow) {
            return this.getWFView();
        } else {
            if (viewParams && viewParams.srfwf && this.InWorkflowArray.indexOf(viewParams.srfwf) !== -1) {
                return this.getWFView();
            }
        }
        let strPDTViewParam: string = await this.getDESDDEViewPDTParam(curData, bDataInWF, bWFMode);
        return this.allViewMap.get(strPDTViewParam);
    }

	/**
	 * 获取实体单数据实体视图预定义参数
	 *
	 * @param curData 当前数据
	 * @param bDataInWF 是否有数据在工作流中
	 * @param bWFMode   是否工作流模式
	 * @memberof IBIZBOOKUIServiceBase
	 */
	public async getDESDDEViewPDTParam(
		curData: any,
		bDataInWF: boolean,
		bWFMode: boolean
	) {
		let strPDTParam: string = '';
		if (bDataInWF) {
			// TODO 判断数据是否在流程中
		}
		// TODO 多表单
		const multiFormDEField: string | null = null;

		const isApp = App.getProjectSetting().isApp;
		if (multiFormDEField) {
			const objFormValue: string = curData[multiFormDEField];
			if (isApp) {
				return 'MOBEDITVIEW:' + objFormValue;
			}
			return 'EDITVIEW:' + objFormValue;
		}
		if (isApp) {
			if (this.getDEMainStateTag(curData)) {
				return `MOBEDITVIEW:MSTAG:${this.getDEMainStateTag(curData)}`;
			}
			return 'MOBEDITVIEW:';
		}
		if (this.getDEMainStateTag(curData)) {
			return `EDITVIEW:MSTAG:${this.getDEMainStateTag(curData)}`;
		}
		return 'EDITVIEW:';
	}

  /**
    * 执行界面逻辑
    * @param logicTag 界面逻辑标识
    * @param context 应用上下文 
    * @param viewParams 视图参数
    * @param data 业务数据
    * @param event 事件对象
    * @param ability 当前环境能力
	* @memberof IBIZBOOKUIServiceBase
    */
  public async executeUILogic<T extends IAbility>(logicTag: string, context: IContext, viewParams: IParam, data: IParam[], event: MouseEvent, ability: T): Promise<IUIActionResult> {
		if (logicTag === "CustomEdit") {
			return await CustomEditUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "CustomViewFormLoad") {
			return await CustomViewFormLoadUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "CustomViewGridLoad") {
			return await CustomViewGridLoadUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "FormLoad") {
			return await FormLoadUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "GridLoad") {
			return await GridLoadUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "PrintParams") {
			return await PrintParamsUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "cancelSelect") {
			return await CancelSelectUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "customViewDestroy") {
			return await CustomViewDestroyUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "grid_load") {
			return await Grid_loadUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "setRouteParam") {
			return await SetRouteParamUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "uilogic_test") {
			return await Uilogic_testUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "uilogic_test_test") {
			return await Uilogic_test_testUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		if (logicTag === "uilogictest") {
			return await UilogictestUILogic.getInstance().execute(context, viewParams, data[0], event, ability);
		}
		return { ok: true, data: null };
  }
}